<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
    <h:body>	
		<ui:composition template="/admin/template.xhtml">		    			
		<p:panel header="Bannery">	
			<h:panelGrid columns="2">
				<p:panel header="seznam bannerů" style="min-height: 1129px;"> 
						<h:form id="filesForm" >
							<p:dataTable id="seaspmTable" var="file" value="#{bannerBean.downloadFiles}" rowKey="#{file.id}" paginator="true" rows="15" paginatorAlwaysVisible="false" paginatorPosition="bottom" selection="#{bannerBean.selectedDownloadFile}" selectionMode="single" emptyMessage="Žádné sezóny nenalazeny"  tableStyle="min-width:300px;">
							        <p:column headerText="Odkaz" >  
							            <h:outputText value="#{file.description}" />  
							        </p:column>
							        <p:column headerText="Jméno banneru" >  
							            <h:outputText value="#{file.filename}" />  
							        </p:column>
							        <f:facet name="footer">  
						            	<p:commandButton  id="editPizzaButton" icon="ui-icon-pencil" value="smazat banner" update="filesForm,:growl" oncomplete="deleteConfirmation.show()"/>
						                <c:if test="#{bannerBean.count != 5}">
						                <p:commandButton  id="newPizzaButton" icon="ui-icon-document" value="nahrát nový banner"  update="filesForm,:growl" oncomplete="seasonNewDialog.show()"/>  
						       			</c:if>
						       		</f:facet>     
						  	</p:dataTable>
						  	<p:confirmDialog id="confirmDialog" message="Opravdu chcete smazat soubor?" header="Potvrzení smazání" severity="alert" widgetVar="deleteConfirmation">  	                  
				      		   	<p:commandButton id="confirm" value="Ano" update="filesForm,:growl" onclick="deleteConfirmation.hide()" actionListener="#{bannerBean.deleteFile}" />  
				  		    	<p:commandButton id="decline" value="Ne" onclick="deleteConfirmation.hide()"/>   	                  
		  			 		</p:confirmDialog>  
					  	</h:form>
					  <p:dialog id="dialogNew" header="Nový soubor" widgetVar="seasonNewDialog" resizable="false" width="250" showEffect="clip" hideEffect="fold" position="10,10">  
					  <h:form enctype="multipart/form-data">  
					        <h:outputText value="odkaz:"/><h:inputText value="#{bannerBean.fileDescription}"/>
							<p:fileUpload value="#{bannerBean.file}"  mode="simple" /> 
							<h:panelGrid>
							<h:outputText value="Název nahrávaného banneru musí být bez diakritiky!"/>
							</h:panelGrid>
							<p:commandButton value="Uložit banner" ajax="false" actionListener="#{bannerBean.upload}" oncomplete="seasonNewDialog.hide()" />  
						</h:form> 	
					</p:dialog>
				</p:panel>
			</h:panelGrid>
		</p:panel>			
		</ui:composition>	
	</h:body>
</html>